package com.example.hdwx.myapplication.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;


import com.example.hdwx.myapplication.R;
import com.example.hdwx.myapplication.eneity.found_eneitys.FoundTopicEneity;
import com.example.hdwx.myapplication.untils.ImageLoaderUtils;

import java.util.List;

/**
 * Created by hudongwx on 17-2-14.
 */

public class FoundTopicAdapter extends RecyclerView.Adapter<FoundTopicAdapter.FoundTopicHolder>{
    Context context;
    List<FoundTopicEneity> data;
    int num;

    public FoundTopicAdapter(Context context, List<FoundTopicEneity> data, int num) {
        this.context = context;
        this.data = data;
        this.num=num;
    }


    @Override
    public FoundTopicHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        Log.e("qqqq","qqqq++++"+data.size());
        View view = LayoutInflater.from(context).inflate(R.layout.found_topic_item_layout, parent, false);
        return new FoundTopicHolder(view);
    }

    @Override
    public void onBindViewHolder(FoundTopicHolder holder, int position) {
        FoundTopicEneity eneity = data.get(position);
        holder.textView.setText(eneity.getLocationName());
        Log.e("qqqq","qqqq++++"+eneity.getLocationimage_url());

        ImageLoaderUtils.setImageLoader(context,eneity.getLocationimage_url(),holder.imageView);
        holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO 话题区点击事件
            }
        });
    }

    @Override
    public int getItemCount() {

        return data.size();
    }

    class FoundTopicHolder extends RecyclerView.ViewHolder{
        RelativeLayout relativeLayout;
        ImageView imageView;
        TextView textView;
        public FoundTopicHolder(View itemView) {
            super(itemView);
            relativeLayout = (RelativeLayout) itemView.findViewById(R.id.found_topic);
            imageView = (ImageView) itemView.findViewById(R.id.found_topic_img);
            textView = (TextView) itemView.findViewById(R.id.found_topic_text);
        }
    }
}
